package org.zcl.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.zcl.annotation.LogRecord;
import org.zcl.enums.OpType;
import org.zcl.model.ApiResponse;
import org.zcl.model.vo.UserInputVo;
import org.zcl.service.UserInfoService;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author zcl
 * @since 2021-11-25
 */
@RestController
@RequestMapping("/user-info")
@Api(value = "测试接口", tags = "UserController")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/addUser")
    @LogRecord(value = OpType.CREATE, content = "#userVo.name")
    @ApiOperation(value = "创建用户", notes = "创建用户")
    public ApiResponse addUser(@RequestBody @Validated UserInputVo userVo) {
        return userInfoService.addUser(userVo);
    }

    @GetMapping(value = "/getMore")
    @ApiOperation(value = "获取用户列表", notes = "获取用户列表")
    @LogRecord(value = OpType.CREATE, content = "#userVo.name")
    public void getMore() {
        System.out.println("目标方法");
    }

    /**
     * ApiIgnore 使用该注解忽略这个API，不会生成接口文档。可注解在类和方法上
     */
    @ApiIgnore
    @GetMapping(value = "/getAll", produces = "application/json")
    @ApiOperation(value = "获取用户列表", notes = "获取用户列表")
    public Map<String, Object> getAll() {
        Map<String, Object> ret = new HashMap<>();
        ret.put("msg", "获取成功");
        return ret;
    }
}
